var mongoose = require("mongoose");
var msgSchema = mongoose.Schema({
  cid: Number,
  username: String,
  content: String,
  time: {
    type: Date,
    default: new Date()
  }
});
msgSchema.statics = {
  findAll: function(id,cb) {
    return this
      .find({cid:id},null,{limit:6})
      .sort({time: -1})
      .exec(cb);
  },
  findById: function(id, cb) {
    return this
      .findOne({cid:id}, cb);
  }
};
module.exports = msgSchema;